﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//引入命名空间
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string con_access = ConfigurationManager.AppSettings["accessCon"].ToString();//获取配置文件中的数据库连接字符串
        Response.Write("Aceess数据库连接字符串："+con_access);//输出获取的数据库字符串信息
        OleDbConnection oCon = new OleDbConnection(ConfigurationManager.AppSettings["accessCon"]);
        try
        { 
            oCon.Open();//打开数据库连接
            Response.Write("<script>alert('连接成功')</script>");
            oCon.Close();//关闭数据库连接
        }
        catch(Exception ex)
        {
            Response.Write("<script>alert(" + ex.ToString() + ")</script>");
        }
    }
}
